
function Results = print_results_govs(results,dnames,rfe,rcoeffs,sstage)

KR = length(rfe);
KD = length(dnames);

colNames = {'Estimate', 'StdError', 'pValue'};

if sstage == 0

    rowNames = [cellfun(@(t)['MP x ',t],dnames,'UniformOutput',0),...
        cellfun(@(t)['NA x ',t],dnames,'UniformOutput',0),...
        cellfun(@(t)['PVEM x ',t],dnames,'UniformOutput',0),...
        cellfun(@(t)['PRI x ',t],dnames,'UniformOutput',0),...
        cellfun(@(t)['PAN x ',t],dnames,'UniformOutput',0)];
    results([1:3+KR,3+KR+KD+(1:3+KR),2*(3+KR+KD)+(1:2+KR),...
        2*3+2+3*(KR+KD)+(1:2+KR),2*(3+2)+4*(KR+KD)+(1:3+KR)],:) = []; % remove FEs
    
    if isempty(rcoeffs)

        csnames = {'spending'};
        cs2names = {'spending^2'};
        rowNames = [csnames,cs2names,'log_lagged_vote_share','incumbent_governor',rowNames];
        results = results([end-1,end,end-3,end-2,1:end-4],:); % rearrange

    else

        csnames = [{'spending'},{'sigma_spending'}];
        cs2names = [{'spending^2'},{'sigma_spending^2'}];
        rowNames = [csnames,cs2names,'log_lagged_vote_share','incumbent_governor',rowNames];
        results = results([end-3,end-1,end-2,end,end-5,end-4,1:end-6],:);

    end

else

    rowNames = [cellfun(@(t)['PVEM x ',t],dnames,'UniformOutput',0),...
        cellfun(@(t)['PRI x ',t],dnames,'UniformOutput',0)];
    rowNames = ['log_lagged_vote_share','incumbent_governor',rowNames];
    results([1:2+KR,2+KR+KD+(1:2+KR)],:) = []; % remove FEs
    results = results([end-1,end,1:end-2],:); % rearrange

end

Results = array2table(results,'RowNames',rowNames,'VariableNames',colNames(1:size(results,2)));
Results.Properties.DimensionNames{1} = 'Coefficient';



